from devicetest.aw.OpenHarmony import CommonOH
from devicetest.core.test_case import TestCase, Step

from aw.common import common_setup, common_teardown
from aw.pom import DeskTop


class PreTest_RK3568_Basic_Desktop_0200(TestCase, DeskTop):
    # 预置条件：
    # 烧写目标版本后，正常进入桌面
    # 测试步骤：
    # 1、长按桌面空白处，点击添加空白页
    # 2、在空白页长按桌面，点击删除空白页
    # 预期结果：
    # 1、可新增一个空白桌面，且可以左右滑动，桌面无异常
    # 2、空白页被删除，桌面无异常

    def __init__(self, controllers):
        self.TAG = self.__class__.__name__
        TestCase.__init__(self, self.TAG, controllers)

    def setup(self):
        common_setup(self.Phone1)

    def process(self):
        Step('步骤1、长按桌面空白处，点击添加空白页')
        CommonOH.click(self.Phone1, **self.center, mode='LONG')
        CommonOH.touchByText(self.Phone1, '添加空白页')
        Step('预期结果1、可新增一个空白桌面，且可以左右滑动，桌面无异常')
        CommonOH.wait(self.Phone1, 1)
        CommonOH.checkIfTextExist(self.Phone1, '相机', expect=False)
        Step('步骤2、在空白页长按桌面，点击删除空白页')
        CommonOH.click(self.Phone1, **self.center, mode='LONG')
        CommonOH.touchByText(self.Phone1, '删除空白页')
        Step('预期结果2、空白页被删除，桌面无异常')
        CommonOH.wait(self.Phone1, 1)
        CommonOH.checkIfTextExist(self.Phone1, '相机')

    def teardown(self):
        common_teardown(self.Phone1)
